﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using POSSystem.DAL;

namespace POSSystem.BLL
{
    public class View_PaymentHist :_View_PaymentHists
    {
        public static View_PaymentHist GetPaymentsByCustID(int id)
        {
            try
            {
                View_PaymentHist invoices = new View_PaymentHist();
                invoices.Where.CustomerID.Value = id;
                invoices.Query.Load();

                return invoices;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("View_PaymentHist.cs", "GetPaymentsByCustID", ex.StackTrace);
                throw ex;
            }
        }

        public static View_PaymentHist GetPaymentsByCustID(int id, string invoiceNo)
        {
            try
            {
                View_PaymentHist invoices = new View_PaymentHist();
                invoices.Where.CustomerID.Value = id;
                if(invoiceNo != "")
                    invoices.Where.InvoiceNo.Value = invoiceNo;
                invoices.Query.Load();

                return invoices;
            }
            catch (Exception ex)
            {
                ErrorLog.WriteToFile("View_PaymentHist.cs", "GetPaymentsByCustID", ex.StackTrace);
                throw ex;
            }
        }
    }
}
